//---------------------------------------------------------------------------

#ifndef DownloadThreadH
#define DownloadThreadH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <ComCtrls.hpp>

#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdHTTP.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>

#define x_url   0
#define x_size  1
#define x_speed 2
#define x_prog  3
//---------------------------------------------------------------------------
class DownloadThread : public TThread
{            
private:
  AnsiString strUrl,strFilename;
  TComponent* Owner;
  int iFilesize,iCurPosition;
protected:
  void __fastcall Execute();
public:
  TIdHTTP *downloader;
  TFileStream *fStream;
  TListItem *MyShow;
  __fastcall DownloadThread(TComponent* AOwner,TListItem *lvItem,AnsiString url,AnsiString filename);
  void initAll();
  
  void __fastcall Working(TObject *Sender, TWorkMode AWorkMode, const int AWorkCount);
  void __fastcall WorkBegin(TObject *Sender, TWorkMode AWorkMode, const int AWorkCountMax);
  void __fastcall WorkEnd(TObject *Sender, TWorkMode AWorkMode);

  AnsiString SizeToStr(int size);
  void freeAll();
};
//---------------------------------------------------------------------------
#endif
